import LanguageMngTs from "../../Managers/LanguageMngTs";

cc.Class({
    extends: cc.Component,

    properties: {
        labelId:{
            default:null,
            type:cc.Label
        },

        labelRoomId:{
            default:null,
            type:cc.Label
        },

        labelPointValue:{
            default:null,
            type:cc.Label
        },

        labelDeckNum:{
            default:null,
            type:cc.Label
        },

        bgNode:{
            default:null,
            type:cc.Node
        },

        contentParent:{
            default:null,
            type:cc.Node
        }
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    // update (dt) {},

    onInforamtionCloseClicked:function (event) {
        this.gameUIMgr._hideInformation()
    },

    initGameInformation:function (gameUIMgr,id,roomid,pointvalue,decknum) {
        if(this._inited) return
        this._inited = true

        this.gameUIMgr = gameUIMgr
        this.labelId.string = id
        this.labelRoomId.string = roomid
        let isPractice = (cc.gg.dataMgr.room.mode & 0xf) === 0
        this.labelPointValue.string = isPractice?"₹ 0":"₹ "+pointvalue/100
        this.labelDeckNum.string = decknum+" "+LanguageMngTs.getSentence(323)   //Deck(s)
    },

    _showBgMask:function () {
        this.bgNode.active = true
        this.bgNode.width = cc.winSize.width
        this.bgNode.height = cc.winSize.height
        let middlePos = cc.find("Canvas").convertToWorldSpaceAR(cc.Vec2.ZERO)
        this.bgNode.position = this.bgNode.parent.convertToNodeSpaceAR(middlePos)
    },

    _hideBgMask:function () {
        this.bgNode.active = false
        // this.bgNode.width = cc.winSize.width
        // this.bgNode.height = cc.winSize.height
        // this.bgNode.position = cc.Vec2.ZERO
    },

    showInformation:function () {
        this._showBgMask()
        cc.gg.logicUtil.windowEnterFromTop(this.contentParent)
    },

    hideInformation:function () {
        this._hideBgMask()
        cc.gg.logicUtil.windowOutToBottom(this.contentParent)
    },
});
